package com.example.infrastructure.api.organization.dto;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import lombok.Data;

import java.util.Objects;
import java.util.Set;

/**
 * TODO
 *
 * @author lxh
 * @date 2020/11/17 下午12:46
 **/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "orgId")
public class OrganizationDto {
    private String orgId;

    private String orgName;

    private OrganizationDto parent;

    private Set<OrganizationDto> children;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        OrganizationDto that = (OrganizationDto) o;
        return orgId.equals(that.orgId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(orgId);
    }
}
